<div class="container" style="margin-top: 60px;">
	<div class="row" style="margin-top: 10px;">
		<div class="col-lg-12">
			<div class="panel panel-default">
		        <div class="panel-heading">
		            <?php echo $cid == 1 ? '巅峰动态' : '教师风采'; ?>资料
		        </div>
		        <!-- /.panel-heading -->
		        <div class="panel-body">
					<form id="frmNews" role="form" action="/admin/node/<?php echo isset($item) ? "edit/{$item->id}" : "create/{$cid}"; ?>" method="post" data-parsley-validate>
						<div class="form-group">
							<label for="title"><?php echo $cid == 1 ? "标题" : "老师"; ?></label>
							<input type="text" class="form-control" id="title" name="title" placeholder="请填写<?php echo $cid == 1 ? "标题" : "老师"; ?>" value="<?php echo isset($item) ? $item->title : ''; ?>" required>
						</div>
						<div class="form-group">
							<label for="category_id"><?php echo $cid == 1 ? "动态分类" : "课程"; ?></label>
							<select id="category_id" name="category_id" class="form-control" required>
							</select>
						</div>
						<div class="form-group">
							<label for="thumbnail"><?php echo $cid == 1 ? "缩略图" : "老师头像"; ?></label><br>
							<input type="text" class="form-control" id="thumbnail" name="thumbnail" placeholder="http://www.baidu.com/1.jpg" value="<?php echo isset($item) ? $item->thumbnail : ''; ?>" style="width: 90%; display: inline;">
							<a href="#" class="btn btn-sm btn-info" data-panel='thumbnail' data-toggle="modal" data-target="#modal-upload"> <i class="fa fa-upload"></i> 上传</a>
						</div>
						<div class="form-group">
							<label for="body"><?php echo $cid == 1 ? "内容" : "老师介绍"; ?></label>
							<textarea id="body" name="body" style="width: 100%; height: 300px;"><?php echo isset($item) ? $item->body : ''; ?></textarea>
						</div>
						<div class="form-group">
							<label for="summary"><?php echo $cid == 1 ? "摘要" : "老师概述"; ?></label>
							<textarea name="summary" style="width: 100%; height: 50px;" placeholder="列表页显示的内容，内容请不要太长"><?php echo isset($item) ? $item->summary : ''; ?></textarea>
						</div>
						<div class="form-group">
							<label for="sort">排序值</label>
							<input type="number" class="form-control" id="sort" name="sort" placeholder="请输入1-255之间的整数，数字越小越靠前显示" value="<?php echo isset($item) ? $item->sort : ''; ?>">
						</div>
						<div class="form-group">
							<label for="url">链接</label>
							<input type="text" class="form-control" id="url" name="url" placeholder="填写该链接后，内容将失效" value="<?php echo isset($item) ? $item->url : ''; ?>">
						</div>
						<div class="form-group">
							<label for="tags">标签</label>
							<input type="text" class="form-control" id="tags" name="tags" placeholder="多个标签请“,”分隔(如：新闻,活动,公告)" value="<?php echo isset($item) ? $item->tags : ''; ?>">
						</div>
						<div class="form-group" style="text-align: center;">
							<a href="/admin/node?cid=<?php echo $cid != 1 ? 2 : 1; ?>" class="btn btn-default"> 返回列表页 </a> 
							<button type="submit" class="btn btn-success"> <?php echo isset($item) ? '更新' : '发布'; ?><?php echo $cid == 1 ? '动态' : '教师风采'; ?> </button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<?php echo render('edu/public/upload'); ?>

<script type="text/javascript">
$(function(){
	$.get('/admin/category?cid=<?php echo $cid;?>', 
		function(data, status){
			if(data.status == 'succ'){
				$('#category_id').empty();
				for (var i = 0; i < data.data.length; i++) {
					var item = data.data[i];
					$('#category_id').append("<option value='" + item.id + "' " + (<?php echo isset($item) ? $item->category_id : '""';?>  == item.id ? ' selected="selected"' : '') + ">" + item.name + "</option>");
				}
			}			
		}, 'json');
});
</script>

<script type="text/javascript" src="/assets/third-party/editor/kindeditor-min.js"></script>
<script type="text/javascript" src="/assets/third-party/editor//lang/zh_CN.js"></script>
<script type="text/javascript">
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="body"]', {
			allowFileManager : false
		});
	});
</script>

<script type="text/javascript">
    var path = 'images';
    var imgpanel = '';


    function callback(file, data){
        var json = eval('(' + data + ')');
        if(json.status == 'succ'){
            $("#thumbnail").val(json.data);
        }else{
            alert(json.msg);
        }
    }
</script>